package com.neulogistics.contrib.warehouse.infrastructure.persistence.orm.po;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;

/**
 * 库房信息表
 * @TableName tb_warehouse
 */
@TableName(value ="tb_warehouse", autoResultMap = true)
@Data
public class WarehousePO implements Serializable {
    /**
     * 库房id
     */
    @TableId(value = "warehouse_id", type = IdType.AUTO)
    private Integer warehouseId;

    /**
     * 库房名
     */
    @TableField(value = "warehouse_name", condition = SqlCondition.LIKE)
    private String warehouseName;

    /**
     * 库房地址{省，市，区，详细}
     */
    @TableField(value = "warehouse_address", typeHandler = JacksonTypeHandler.class)
    private JSONObject warehouseAddress;

    /**
     * 库房等级：0：中心库房；1：分站库房
     */
    @TableField(value = "warehouse_level")
    private Integer warehouseLevel;

    /**
     * 生成时间
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 是否删除
     */
    @TableField(value = "deleted")
    @TableLogic(value = "0", delval = "1")
    private Integer deleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        WarehousePO other = (WarehousePO) that;
        return (this.getWarehouseId() == null ? other.getWarehouseId() == null : this.getWarehouseId().equals(other.getWarehouseId()))
            && (this.getWarehouseName() == null ? other.getWarehouseName() == null : this.getWarehouseName().equals(other.getWarehouseName()))
            && (this.getWarehouseAddress() == null ? other.getWarehouseAddress() == null : this.getWarehouseAddress().equals(other.getWarehouseAddress()))
            && (this.getWarehouseLevel() == null ? other.getWarehouseLevel() == null : this.getWarehouseLevel().equals(other.getWarehouseLevel()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((this.getWarehouseId() == null) ? 0 : this.getWarehouseId().hashCode());
        result = prime * result + ((getWarehouseName() == null) ? 0 : getWarehouseName().hashCode());
        result = prime * result + ((getWarehouseAddress() == null) ? 0 : getWarehouseAddress().hashCode());
        result = prime * result + ((getWarehouseLevel() == null) ? 0 : getWarehouseLevel().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", warehouseId=").append(warehouseId);
        sb.append(", warehouseName=").append(warehouseName);
        sb.append(", warehouseAddress=").append(warehouseAddress);
        sb.append(", warehouseLevel=").append(warehouseLevel);
        sb.append(", createTime=").append(createTime);
        sb.append(", deleted=").append(deleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}